﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Common.TokenReader;

namespace Data.GameData
{
    public class GameObject : BaseObject, ICloneable
    {
        private Guid id;

        public GameObject()
        {
            id = Guid.NewGuid();
        }

        public Guid Id
        {
            get { return id; }
            protected set { id = value; }
        }

        public virtual bool BuildFromMetaData(MetaObject meta)
        {
            return true;
        }



        public override void Save()
        {
            base.Save();
        }

        internal override void Update()
        {
            throw new Exception("Invalid code path, Method must be overridden.");
        }

        internal override void DeleteNow()
        {
            throw new Exception("Invalid code path, Method must be overridden.");
        }

        internal override void SaveValues()
        {
            throw new Exception("Invalid code path, Method must be overridden.");
        }

        internal override void LoadValues()
        {
            throw new Exception("Invalid code path, Method must be overridden.");
        }

        internal override void InitialiseObject()
        {
            throw new Exception("Invalid code path, Method must be overridden.");
        }


        /// <summary>
        /// Returns a copy of the object
        /// </summary>
        /// <returns>The copy of the object</returns>
        public object Copy()
        {
            return this.MemberwiseClone();
        }
       
        #region ICloneable Members
        /// <summary>
        /// Return a new version of this object, but assign a new objectId to it.
        /// </summary>
        /// <returns>The new version of the object</returns>
        public override object Clone()
        {
            GameObject obj = base.Clone() as GameObject;
            obj.id = Guid.NewGuid();

            return obj;
        }
        #endregion
    }
}
